/**
 * Created by iwm on 2017/1/23.
 */
$(document).ready(function () {
    $(".verify").each(function () {

        var id = $(this)[0].id;
        var name = $("#" + id).parent().parent().find('td').eq(1).text();
        var reason = $("#" + id).parent().parent().find('td').eq(4).text();

        $(this).click(function () {
            $('#cirid').attr('value', id);
            $('#cirname').val(name);
            //$("#cirname").val('xxxxx')
            $('#reason').val(reason);
            $('#myModal').modal("show");
        });
    });
    verifyCircle();
});

function verifyCircle() {
    var btn = $("#confirm");
    btn.click(function () {

        console.log($('#cirid').val());
        console.log($('#status').val());
        var cirid = $('#cirid').val();
        var status = $('#status').val();
        var myData = new FormData();
        myData.append('cir_id', cirid);
        myData.append('status', status);
        //console.log(myData);

        $.ajax({
            url: '/home/circle/approvecircle',
            timeout: 100000,
            type: 'post',
            processData: false,
            contentType: false,
            dataType: 'json',
            data: myData,
            success: function (rs) {
                if (rs.errno != 0) {
                    toastr.error(rs.errmsg, '', {positionClass: 'toast-bottom-center'});
                }
                if (rs.errno == 0) {
                    toastr.success(rs.errmsg);
                    window.location.reload();
                    $('#myModal').modal('hide');
                }
            },
            error: function () {
                toastr.error('系统错误', '', {positionClass: 'toast-bottom-center'});
            }
        });
        //alert(test);
    });

}